//
//  NSString+Chinese.h
//  iwubi
//
//  Created by betahuang on 2018/1/10.
//  Copyright © 2018年 betahuang. All rights reserved.
//

#import "NSString+Chinese.h"

@implementation NSString (Chinese)
- (BOOL)isChinese
{
    NSString *match = @"(^[\u4e00-\u9fa5]+$)";
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF matches %@", match];
    return [predicate evaluateWithObject:self];
}

- (NSData*)gbk {
    unsigned long encode = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
    return [self dataUsingEncoding:encode];
}
@end
